package com.smt.modules.app.controller;

import com.smt.modules.app.utils.ImageFactoryUtils;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 根据文件扩展获取文件系统图标
 *
 * @author zhangyi
 * @date 2018/11/9 18:48
 */
@Controller
@RequestMapping("/app/image")
@Api(tags = {"AppImageFactoryController"},description = "根据文件扩展获取文件系统图标",hidden = true)
public class AppImageFactoryController {

    /**
     * 获取文件名
     *
     * @param dirName
     * @param response
     */
    @PostMapping("/get")
    public void get(@RequestParam("dirName") String dirName, HttpServletResponse response) {
        OutputStream sos = null;
        try {
            ImageFactoryUtils imageFactoryUtils = new ImageFactoryUtils();
            sos = response.getOutputStream();
//            ImageIO.write((RenderedImage) jLabel, "png", sos);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
            try {
                sos.flush();
                sos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
